home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Online / Apache / wwwcount2.4 / Gen-conf < prev    next >
Text File  |  1997-11-23  |  13KB  |  502 lines

  1. #!/bin/sh
  2. ###
  3. # $Revision: 2.3 $
  4. # $Date: 1996/05/03 02:20:22 $
  5. #
  6. # Automatically generate  the conter configuration file
  7. ###
  8. #
  9. # it was hard coded 2.3, thanks to craig@picasso.ppco.com for reporting.
  10. # nov-05-1997
  11. #
  12. Version=`cat ./VERSION`
  13. ConfFile="count.cfg"
  14. nick=0
  15. ignc=0
  16. alfc=0
  17. strict=0
  18. rgb=0
  19.  
  20. (echo "hi there\c" ; echo " ") >.echotest
  21. if grep c .echotest >/dev/null 2>&1 ; then
  22. n='-n'
  23. c=''
  24. else
  25. n=''
  26. c='\c'
  27. fi
  28. rm -f .echotest >/dev/null 2>&1
  29.  
  30. cat << EOSI
  31.     Welcome to the conf file generation procedure of Count $Version
  32.  
  33.     This program creates a workable conf file for your host only, you have
  34.     to edit it by hand if you want to add other hosts. The file will have
  35.     enough comments in it to help you out. You also have to hand edit it
  36.     if you want to use netmasks to mask out a entire network or a specific
  37.     range of hosts in a network.
  38.  
  39.     First of all you must know your 
  40.         1) fully qualified domain name (FQDN), for example,
  41.             if your hostname is foo and your domain name is foobar.com,
  42.             then your FQDN is
  43.             foo.foobar.com
  44.  
  45.         2) IP address of your host, for example, 
  46.             192.165.155.2 
  47.  
  48.         3) If your host has any nickname defined, for example,
  49.             www.foobar.com. The nick name also has to be FQDN.
  50.  
  51.         4) If you want to allow automatic datafile creation (bad thing).
  52.  
  53.         5) If you want to run the counter in strict mode.
  54.  
  55.         6) If you want to ignore access hits from your own host.
  56.  
  57. EOSI
  58.  
  59. echo $n "Continue [y|n]$c? "
  60. read answer
  61.  
  62. if [ .$answer = . ]
  63. then
  64.     answer=x 
  65. fi
  66.     until [ $answer = "y" -o $answer = "Y" -o $answer = "n" -o $answer = "N" ]
  67.     do
  68.         echo $n "Continue [y|n]$c? "
  69.         read answer
  70.             if [ .$answer = . ]
  71.             then
  72.                 answer=x
  73.             fi
  74.     done   
  75.     
  76.     case $answer in
  77.         y|Y)
  78. ######
  79. # Enter hostname  --Starts
  80. #####
  81. cat<<EOE
  82.         
  83.     No Error checking will be done with your hostname, therefore,
  84.     you better make sure you are entering the fully qualified domain name.
  85.           
  86. EOE
  87.     echo $n "* Enter your fully qualified domain name [no default]:$c "
  88.     read hostname     
  89.    host=`echo $hostname|awk -F. '{print $1}'`
  90.    dom1=`echo $hostname|awk -F. '{print $2}'`
  91.    dom2=`echo $hostname|awk -F. '{print $3}'`
  92.     until [ .$hostname != . -a .$host != . -a .$dom1 != . -a .$dom2 != . ]
  93.     do
  94.         echo $n "* Enter your fully qualified domain name [no default]:$c "
  95.         read hostname
  96.         host=`echo $hostname|awk -F. '{print $1}'`
  97.         dom1=`echo $hostname|awk -F. '{print $2}'`
  98.         dom2=`echo $hostname|awk -F. '{print $3}'`
  99.     done
  100.  
  101. ######
  102. # Enter hostname  --Ends
  103. #####
  104.  
  105. ######
  106. # Enter ip address  --Starts
  107. #####
  108. cat<<EOE
  109.  
  110.     No Error checking will be done with your IP address, therefore,
  111.     you better make sure you are entering the correct IP address.
  112.  
  113. EOE
  114.     echo $n "* Enter your IP address [no default]:$c "
  115.     read ipaddress
  116.     oct1=`echo $ipaddress|awk -F. '{print $1}'`
  117.     oct2=`echo $ipaddress|awk -F. '{print $2}'`
  118.     oct3=`echo $ipaddress|awk -F. '{print $3}'`
  119.     oct4=`echo $ipaddress|awk -F. '{print $4}'`
  120.     until [ .$ipaddress != . -a .$oct1 != . -a .$oct2 != .\
  121.         -a .oct3 != . -a .$oct4 != . ]
  122.     do   
  123.         echo $n "* Enter your IP address [no default]:$c "
  124.         read ipaddress
  125.     oct1=`echo $ipaddress|awk -F. '{print $1}'`
  126.     oct2=`echo $ipaddress|awk -F. '{print $2}'`
  127.     oct3=`echo $ipaddress|awk -F. '{print $3}'`
  128.     oct4=`echo $ipaddress|awk -F. '{print $4}'`
  129.     done
  130.  
  131. ######
  132. # Enter ip address  --Ends
  133. #####
  134.  
  135. ######
  136. # ask for nick --Starts
  137. #####
  138.    echo ""
  139.    echo $n "* Does your host have any nickname [y|n]:$c? "
  140.    read answer  
  141.    if [ .$answer = . ]  
  142.    then
  143.         answer=x
  144.    fi
  145.    until [ $answer = "y" -o $answer = "Y" -o $answer = "n" -o $answer = "N" ]
  146.    do
  147.         echo $n "* Does your host have any nickname (FQDN) [y|n]:$c? "
  148.         read answer
  149.         if  [ .$answer = . ]
  150.         then
  151.             answer=x
  152.         fi
  153.    done
  154.  
  155.     case $answer in
  156.         y|Y)
  157.             nick=1
  158.             echo $n "* Enter your host's nickname (FQDN) [no default]:$c "
  159.             read nickname
  160.             nhost=`echo $nickname|awk -F. '{print $1}'`
  161.             ndom1=`echo $nickname|awk -F. '{print $2}'`
  162.             ndom2=`echo $nickname|awk -F. '{print $3}'`
  163.     until [ .$nickname != . -a .$nhost != . -a .$ndom1 != . -a .$ndom2 != . ]
  164.     do
  165.         echo $n "* Enter your host's nickname [no default]:$c "
  166.         read nickname
  167.         nhost=`echo $nickname|awk -F. '{print $1}'`
  168.         ndom1=`echo $nickname|awk -F. '{print $2}'`
  169.         ndom2=`echo $nickname|awk -F. '{print $3}'`
  170.     done
  171.         ;;
  172.         n|N)
  173.         ;;
  174.         *)
  175.             echo "Illegal choice"
  176.      esac
  177.     until [ .$hostname != . -a .$host != . -a .$dom1 != . -a .$dom2 != . ]
  178.     do
  179.         echo $n "* Enter your fully qualified domain name [no default]:$c "
  180.         read hostname
  181.         host=`echo $hostname|awk -F. '{print $1}'`
  182.         dom1=`echo $hostname|awk -F. '{print $2}'`
  183.         dom2=`echo $hostname|awk -F. '{print $3}'`
  184.     done
  185. ######
  186. # ask for nick --Ends
  187. #####
  188.         ;;
  189.         n|N)
  190.             echo "Exiting..Better luck next time!"
  191.             exit 1
  192.         ;;
  193.  
  194.         *)
  195.             echo ""
  196.             echo "Illegal choice"
  197.      esac
  198.  
  199.  
  200. ###
  201. # allow file creation?
  202. ###
  203. cat<<EOAF
  204.     
  205.     Now you need to decide if you will allow the users to create datafiles
  206.     for them automatically. If you allow, the counter datafile will be
  207.     created for the user if it does not exist and a pre-determined counter
  208.     number will be inserted to it. If you do not allow, you have to create
  209.     the datafile for each user, provided that the data directory has proper
  210.     write permission.  
  211.  
  212.     Allowing users to create datafile is very convenient, as you do not
  213.     have to be asked all the time when someone decides to use the counter.
  214.     But the dark side of this is, anyone will be able create datafiles in
  215.     the data directory. The decision is yours.
  216.  
  217. EOAF
  218. echo $n "* Do you want to allow automatic file creation [[y|n]$c? "
  219. read answer
  220. if [ .$answer = . ]
  221. then
  222.     answer=x
  223. fi
  224. until [ $answer = "y" -o $answer = "Y" -o $answer = "n" -o $answer = "N" ] 
  225. do
  226.     echo $n "* Do you want to allow automatic file creation [[y|n]$c? "
  227.         read answer
  228.             if [ .$answer = . ]
  229.             then
  230.                 answer=x
  231.             fi
  232.     done
  233.     
  234.     case $answer in
  235.         y|Y)
  236.             alfc=1
  237.         ;;
  238.  
  239.         n|N)
  240.             alfc=0
  241.         ;;
  242.  
  243.         *)
  244.             echo ""
  245.             echo "Illegal choice"
  246.      esac
  247.  
  248. ##
  249. # compile in strict mode or not
  250. ###
  251. cat <<EOSM
  252.  
  253.     Now you need to decide if you want to compile the program in strict   
  254.     mode. If you compile the program in strict mode, the browsers which
  255.     do not return the environment variable HTTP_REFERER, will not be
  256.     served, that is no access hit will be recorded, no time or date
  257.     will be displayed. Instead, a string 888888 will be displayed. 
  258.     
  259.     The strict mode ensures that your counter data file can not be messed
  260.     by accessing the counter remotely from a browser which does not return
  261.     that variable. Note, good browsers like netscape returns this
  262.     variable. Other browsers e.g. Mosaic does not return this variable in
  263.     IMG GET method at this time.  This strict mode is experimental at this
  264.     time!
  265.  
  266. EOSM
  267. echo $n "* Do you want the program to run in strict mode [[y|n]$c? "
  268. read answer
  269. if [ .$answer = . ]
  270. then
  271.     answer=x
  272. fi
  273. until [ $answer = "y" -o $answer = "Y" -o $answer = "n" -o $answer = "N" ] 
  274. do
  275. echo $n "* Do you want the program to run in strict mode [[y|n]$c? "
  276.         read answer
  277.             if [ .$answer = . ]
  278.             then
  279.                 answer=x
  280.             fi
  281.     done
  282.     
  283.     case $answer in
  284.         y|Y)
  285.             strict=1
  286.         ;;
  287.  
  288.         n|N)
  289.             strict=0
  290.         ;;
  291.  
  292.         *)
  293.             echo ""
  294.             echo "Illegal choice"
  295.      esac
  296.  
  297. ########
  298. echo $n "* Do you want to ignore access hits from your own host [y|n]$c? "
  299. read answer
  300.         
  301. if [ .$answer = . ]
  302. then
  303.     answer=x
  304. fi
  305.     until [ $answer = "y" -o $answer = "Y" -o $answer = "n" -o $answer = "N" ]
  306.     do
  307.         echo $n "Do you want to ignore access from your own host [y|n]$c? "
  308.         read answer
  309.             if [ .$answer = . ]
  310.             then
  311.                 answer=x
  312.             fi
  313.     done
  314.       
  315.     case $answer in
  316.         y|Y)
  317.             ignc=1
  318.         ;;
  319.  
  320.         n|N)
  321.             ignc=0
  322.         ;;
  323.  
  324.         *)
  325.             echo ""
  326.             echo "Illegal choice"
  327.      esac
  328.  
  329. ##
  330. # allow to use color name datase? --starts
  331. ##
  332. cat<<EORG
  333.  
  334.     Ok, do you want the users to use the file rgb.txt for color name
  335.     lookup? It is very inefficient to search this file every time the
  336.     web page is loaded. If you answer yes, the color name
  337.     will be looked up and used. If you answer no, the color will be
  338.     looked up but instead of the counter image, the RGB value will
  339.     be displayed and the user will be asked to use the RGB value
  340.     instead. This will prevent users to use this file. However,
  341.     the convenience of allowing to use rgb.txt file is that color name e.g,
  342.     red, gold etc.  can be used instead of cryptic red, green and blue
  343.     components of the color.
  344.     
  345. EORG
  346. echo $n "* Allow using the rgb.txt file [y|n]$c? "
  347. read answer
  348.         
  349. if [ .$answer = . ]
  350. then
  351.     answer=x
  352. fi
  353.     until [ $answer = "y" -o $answer = "Y" -o $answer = "n" -o $answer = "N" ]
  354.     do
  355.         echo $n "*  Allow using the rgb.txt file [y|n]$c? "
  356.         read answer
  357.             if [ .$answer = . ]
  358.             then
  359.                 answer=x
  360.             fi
  361.     done
  362.       
  363.     case $answer in
  364.         y|Y)
  365.             rgb=1
  366.         ;;
  367.  
  368.         n|N)
  369.             rgb=0
  370.         ;;
  371.  
  372.         *)
  373.             echo ""
  374.             echo "Illegal choice"
  375.      esac
  376.  
  377. ##
  378. # allow to use color name datase? --ends
  379. ##
  380. ##########
  381.  
  382. d=`date`
  383. hn=`hostname`
  384. cat<<IGH>$ConfFile
  385. #######
  386. # configuration file for Count $Version
  387. # Automatically generated from user input by the script Gen-conf
  388. # Created on: $d
  389. # Edit by hand, if you need to add something
  390. ##############################################
  391. ####
  392. # BLOCK 1
  393. # Allow automatic datafile creation or not
  394. # it's a required block. 1 means allow, 0 means do not allow.
  395. ####
  396. IGH
  397. if [ $alfc -eq 1 ]
  398. then
  399.    echo "{" >> $ConfFile
  400.    echo "1" >> $ConfFile
  401.    echo "}" >> $ConfFile 
  402. else
  403.    echo "{" >> $ConfFile
  404.    echo "0" >> $ConfFile
  405.    echo "}" >> $ConfFile 
  406. fi
  407. cat<<STM>>$ConfFile
  408. ###
  409. # BLOCK 2
  410. # run the program in strict mode or not.
  411. # it's a required block. 1 means strict, 0 means not strict.
  412. ###
  413. STM
  414. if [ $strict -eq 1 ]
  415. then
  416.    echo "{" >> $ConfFile
  417.    echo "1" >> $ConfFile
  418.    echo "}" >> $ConfFile 
  419. else
  420.    echo "{" >> $ConfFile
  421.    echo "0" >> $ConfFile
  422.    echo "}" >> $ConfFile 
  423. fi
  424.  
  425. cat<<BLOCK3>>$ConfFile
  426. ####
  427. # BLOCK 3
  428. # Allow to use RGB color database. 1 means allow, 0 means don't.
  429. # convenient to use because colorname e.g., red, gold etc can
  430. # be used instead of rgb components of the color, however it's
  431. # very inefficient to lookup.
  432. ####
  433. BLOCK3
  434. if [ $rgb -eq 1 ]
  435. then
  436.     echo "{" >> $ConfFile
  437.     echo "1" >> $ConfFile
  438.     echo "}" >> $ConfFile
  439. else
  440.     echo "{" >> $ConfFile
  441.     echo "0" >> $ConfFile
  442.     echo "}" >> $ConfFile
  443. fi
  444. cat<<IGH2>>$ConfFile
  445. ####
  446. # BLOCK 4
  447. # Ignore count block, you might want to ignore the local sites.
  448. # If you do not want to ignore any hosts from
  449. # counting, just put { on one line and } on the next line but make sure
  450. # the braces exist!
  451. # It's a required block.
  452. ##
  453. # netmasks can be used to ignore a entire network or a specific
  454. # range of hosts in the network. Read the counter documentation to
  455. # know about netmasks. Wild carding can be used.
  456. # one item per line.
  457. ####
  458. IGH2
  459. if [ $ignc -eq 1 ]
  460. then
  461.     echo "{" >> $ConfFile
  462.     echo "$ipaddress" >> $ConfFile
  463.     echo "}" >> $ConfFile
  464. else
  465.     echo "{" >> $ConfFile
  466.     echo "}" >> $ConfFile
  467. fi
  468. # generate auth block
  469. cat<<EOBL>>$ConfFile
  470. ####
  471. # BLOCK 5
  472. # Auth block
  473. # All possible names and IP addresses by which your host can be referred.
  474. # These hosts can access the counter remotely or locally. Host running
  475. # the http server must exist here. Wild card can be used.
  476. #
  477. # If Count.cgi was built with the USE_DNS macro defined, this block need
  478. # only list valid IP addresses.  In that case, it is recommended that this
  479. # block only contain wild-carded IP addresses.  Fewer entries in this
  480. # block will decrease start-up overhead.
  481. # one item per line.
  482. ##
  483. EOBL
  484. echo "{" >> $ConfFile
  485. echo "$hostname" >> $ConfFile
  486. echo "$host" >>$ConfFile
  487. echo "$ipaddress" >> $ConfFile
  488. if [ $nick -eq 1 ]
  489. then
  490.     echo "$nickname" >> $ConfFile
  491.     echo "$nhost" >>$ConfFile
  492. fi
  493. echo "test.counter.com" >> $ConfFile
  494. echo "}" >>$ConfFile
  495.  
  496. cat <<EOCF
  497.  
  498.     Created conf file "$ConfFile"
  499.     Please look at it, you might want to edit it!
  500.  
  501. EOCF
  502.